~ chicken-core (chicken-5) /manual/Module (chicken pathname)


  1[[tags: manual]]
  2[[toc:]]
  3
  4== Module (chicken pathname)
  5
  6This module provides procedures for manipulating paths.  If you want
  7to operate on the files and directories which the paths represent, see
  8[[Module (chicken file)]].
  9
 10=== absolute-pathname?
 11
 12<procedure>(absolute-pathname? PATHNAME)</procedure>
 13
 14Returns {{#t}} if the string {{PATHNAME}} names an absolute
 15pathname, and returns {{#f}} otherwise.
 16
 17=== decompose-pathname
 18
 19<procedure>(decompose-pathname PATHNAME)</procedure>
 20
 21Returns three values: the directory-, filename- and extension-components
 22of the file named by the string {{PATHNAME}}.
 23For any component that is not contained in {{PATHNAME}}, {{#f}} is returned.
 24
 25=== make-pathname
 26=== make-absolute-pathname
 27
 28<procedure>(make-pathname DIRECTORY FILENAME [EXTENSION])</procedure><br>
 29<procedure>(make-absolute-pathname DIRECTORY FILENAME [EXTENSION])</procedure>
 30
 31Returns a string that names the file with the
 32components {{DIRECTORY, FILENAME}} and (optionally)
 33{{EXTENSION}} with {{SEPARATOR}} being the directory separation indicator
 34(usually {{/}} on UNIX systems and {{\}} on Windows, defaulting to whatever
 35platform this is running on). 
 36{{DIRECTORY}} can be {{#f}} (meaning no
 37directory component), a string or a list of strings. {{FILENAME}}
 38and {{EXTENSION}} should be strings or {{#f}}.
 39{{make-absolute-pathname}} returns always an absolute pathname.
 40
 41=== pathname-directory
 42=== pathname-file
 43=== pathname-extension
 44
 45<procedure>(pathname-directory PATHNAME)</procedure><br>
 46<procedure>(pathname-file PATHNAME)</procedure><br>
 47<procedure>(pathname-extension PATHNAME)</procedure>
 48
 49Accessors for the components of {{PATHNAME}}. If the pathname does
 50not contain the accessed component, then {{#f}} is returned.
 51
 52=== pathname-replace-directory
 53=== pathname-replace-file
 54=== pathname-replace-extension
 55
 56<procedure>(pathname-replace-directory PATHNAME DIRECTORY)</procedure><br>
 57<procedure>(pathname-replace-file PATHNAME FILENAME)</procedure><br>
 58<procedure>(pathname-replace-extension PATHNAME EXTENSION)</procedure>
 59
 60Return a new pathname with the specified component of {{PATHNAME}}
 61replaced by a new value.
 62
 63=== pathname-strip-directory
 64=== pathname-strip-extension
 65
 66<procedure>(pathname-strip-directory PATHNAME)</procedure><br>
 67<procedure>(pathname-strip-extension PATHNAME)</procedure>
 68
 69Return a new pathname with the specified component of {{PATHNAME}}
 70stripped.
 71
 72=== normalize-pathname
 73
 74<procedure>(normalize-pathname PATHNAME [PLATFORM])</procedure>
 75
 76Performs a simple "normalization" on the {{PATHNAME}}, suitably for
 77{{PLATFORM}}, which should be one of the symbols {{windows}}
 78or {{unix}} and defaults to on whatever platform is currently
 79in use. All relative path elements and duplicate separators are processed 
 80and removed.  If {{NAME}} ends with
 81a {{/}} or is empty, the appropriate slash is appended to the tail.
 82
 83No directories or files are actually tested for existence; this 
 84procedure only canonicalises path syntax.
 85
 86=== directory-null?
 87
 88<procedure>(directory-null? DIRECTORY)</procedure>
 89
 90Does the {{DIRECTORY}} consist only of path separators and the period?
 91
 92{{DIRECTORY}} may be a string or a list of strings.
 93
 94=== decompose-directory
 95
 96<procedure>(decompose-directory DIRECTORY)</procedure>
 97
 98Returns 3 values: the {{base-origin}}, {{base-directory}}, and the
 99{{directory-elements}} for the {{DIRECTORY}}.
100
101; {{base-origin}} : a {{string}} or {{#f}}. The drive, if any.
102; {{base-directory}} : a {{string}} or {{#f}}. A directory-separator when {{DIRECTORY}} is an {{absolute-pathname}}.
103; {{directory-elements}} : a {{list-of string}} or {{#f}}. The non-directory-separator bits.
104
105{{DIRECTORY}} is a {{string}}.
106
107* On Windows {{(decompose-directory "c:foo/bar")}} => {{"c:" #f ("foo" "bar")}}
108
109=== Windows specific notes
110
111Use of UTF8 encoded strings for pathnames is not supported. Windows
112uses a 16-bit UNICODE encoding with special system calls for
113wide-character support.  Only single-byte string encoding can be used.
114
115---
116Previous: [[Module (chicken module)]]
117
118Next: [[Module (chicken platform)]]
Trap